<?php
/**
 * Created by litong on Date: 2019/2/25 0025 上午 8:10
 */
$host="localhost";$username="root";$password="";$dbname="php_study";
$connection = mysqli_connect($host, $username, $password, $dbname);
if(!$connection){
  echo $connection->connect_error;
}
$sql="SELECT id, firstname, lastname FROM my_guests";
$mysqli_result = mysqli_query($connection, $sql);
if($mysqli_result->num_rows>0){
  while($row=mysqli_fetch_assoc($mysqli_result)){
    var_dump($row);
  }
}